﻿<%@ WebHandler Language="C#" Class="Training.Web.AjaxHandler.Loaddata.Administration.Catalog.PositionLoadHandler" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Text;

using SIPO.Library.DataAccess.Administration;
using SIPO.Library.DomainObject.Administration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;

using Training.Library.Enum;
using Training.Web.Support;

using Newtonsoft.Json.Linq;

namespace Training.Web.AjaxHandler.Loaddata.Administration.Catalog
{
    public class PositionLoadHandler : Training.Web.BaseHandler
    {
        PositionRepo PositionDal = new PositionRepo(ConfigurationManager.ConnectionStrings["JobdescConn"].ConnectionString);
        string MethodName = string.Empty;

        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            if (context.Request.Params["method"] != null)
                MethodName = context.Request.Params["method"];


            if (MethodName == "getbydepartment")
            {
                int departmentID = Convert.ToInt32(context.Request.Params["departmentID"].ToString());
                List<Position> list = PositionDal.GetListByDepartmentID(departmentID);
                var result = list.OrderBy(x=>x.PositionName);
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            }



        }


        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}